<style>
#winBodyContainer{padding:0px;overflow-y:scroll;}
</style>
<link href="__PUBLIC__/Js/uploadify.v3.2.1/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="__PUBLIC__/Js/uploadify.v3.2.1/jquery.uploadify.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$('#file-upload-{$upload_field}').uploadify({
		'formData' : { '<?php echo session_name();?>' : '<?php echo session_id();?>' },
		'buttonText':'<span class="if if-add"></span>',
		'auto':true,//是否自动上传
		'width' : '100',
		'height' : '100',
		'uploader':'{:URL("File/upload")}',//上传处理程序
		'multi' : {$is_multi ? 'true' : 'false'},//允许同时上传多张图片
		'swf': "__PUBLIC__/Js/uploadify.v3.2.1/uploadify.swf",
		'overrideEvents' : ['onDialogClose','onUploadSuccess','onUploadError','onSelectError'],
		'onSelectError': function (file, errorCode, errorMsg) {
			var msgText = "上传失败==>";  
			switch (errorCode) {  
				case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:  
					msgText += "每次最多上传 " + this.settings.queueSizeLimit + "个文件";  
					break;  
				case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:  
					msgText += "文件大小超过限制( " + this.settings.fileSizeLimit + " )";  
					break;  
				case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:  
					msgText += "文件大小为0";  
					break;  
				case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:  
					msgText += "文件格式不正确，仅限 " + this.settings.fileTypeExts;  
					break;  
				default:  
					msgText += "错误代码：" + errorCode + "\n" + errorMsg;  
			}  
			msgbox(msgText,'error');
		},
		'onUploadError' : function(file, errorCode, errorMsg, errorString) {	//错误提示
			// alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
		},
		'fileTypeDesc':'支持的格式：',
		<switch name="upload_type" >
			<case value="img">//图片后缀
	        	'fileTypeExts':'{$img_ext}',
			</case>
			<case value="app">//客户端后缀
				'fileTypeExts':'*.apk;*.ipa;',
			</case>
			<case value="android">//Android后缀
				'fileTypeExts':'*.apk;',
			</case>
			<case value="ios">//IOS后缀
				'fileTypeExts':'*.ipa;',
			</case>
			<case value="custom">//自定义后缀
				'fileTypeExts':'{$file_exts}',
			</case>
			<default />//所有后缀
				'fileTypeExts':'{$all_ext}',

		</switch>
		'queueSizeLimit' : {$is_multi ? 5 : 1},//上传数量
		'fileSizeLimit':'2MB',//上传文件的大小限制
		'queueID':'upload-queue-list-{$upload_field}',
		//上传到服务器，服务器返回相应信息到data里
		'onUploadSuccess':function(file, data, response){
			if(data){
				if(data == 'err'){
					msgbox('上传文件失败！');
				}else{
					json      = jQuery.parseJSON(data);
					filename  = json.filename;
					file_url  = json.file_url;
					file_id   = json.file_id;
					file_path = json.file_path;
					is_pic    = json.is_pic;

					var html = '<li class="if if-ok file-id-' + file_id + '" file-id="' + file_id + '" is-multi="{$is_multi}" file-path="' + file_path + '" is-pic="' + is_pic + '">';
						html += '<img src="' + file_url + '" alt="">';
						html += '<input type="hidden" name="{$upload_field}[]" value="' + file_id + '">';
						html += '</li>';
					$('#file-upload-btn-{$upload_field}').before(html);
				}
			}else{
				msgbox("不能非法上传文件！");
			}
		},
		//完成处理
		'onQueueComplete':function (argument) {
			<neq name="is_multi" value="1">
			$('#file-upload-btn-{$upload_field}').hide();
			$('.{$upload_field}-btn-upload').show();
			</neq>
			$('.{$upload_field}-btn-upload').hide();
			$('#upload-queue-list-{$upload_field}').hide();
		}
		
	});
});
</script>
<div class="win-upload-content">
	<div class="form_data">
		<div class="mod_name" id="no_pmb">
			<li class="on">
				<a href="{:URL('win_upload', array('upload_type' => $upload_type, 'upload_field' => $upload_field, 'is_multi' => $is_multi, 'upload_file_ext' => $upload_file_ext))}">本地上传</a>
			</li>
			<li>
				<a href="{:URL('win_online', array('upload_type' => $upload_type, 'upload_field' => $upload_field, 'is_multi' => $is_multi, 'upload_file_ext' => $upload_file_ext))}">在线管理</a>
			</li>
		</div>
	</div>
	<ul class="upload-img-box" id="upload-list-{:md5($upload_field)}">
		<li class="add" id="file-upload-btn-{$upload_field}">
			<input id="file-upload-{$upload_field}" type="file" />
		</li>
	</ul>
	<div class="upload-queue-list" id="upload-queue-list-{$upload_field}"></div>
</div>
<div class="win-opt-box">
	<span class="btn btn-confirm confirm-selected-file" to="upload-list-{:md5($upload_field)}" is-multi="{$is_multi}" field="{$upload_field}">确定</span>
	<span class="btn btn-cancel removeWin">取消</span>
</div>